﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Admin/MasterPage.Master" AutoEventWireup="true"
    CodeBehind="AddPhoto.aspx.cs" Inherits="Token.Piker.Web.Admin.NewsAlbum.AddPhoto" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <title>添加新闻图片</title>
    <link href="../js/uploadify/uploadify.css" rel="stylesheet" type="text/css" />
    <style type="text/css">
        .option
        {
            display: none;
        }
    </style>
    <script src="../js/jquery-1.9.1.min.js" type="text/javascript"></script>
    <script src="../js/uploadify/jquery.uploadify.min.js" type="text/javascript"></script>
    <script type="text/javascript">
        $(function () {
            var albumid;
            albumid = $("#<%=hdfAlbumid.ClientID%>").val();
            $("#uploadify").uploadify({
                swf: '../js/uploadify/uploadify.swf',
                uploader: '../js/uploadify/UploadNewsPhoto.ashx',
                cancelImg: '../js/uploadify/uploadify-cancel.png',
                queueID: 'fileQueue',
                buttonText: '浏览',
                fileTypeDesc:'支持的格式：',
                fileTypeExts:'*.jpg;*.jpge;*.gif;*.png',
                auto: false,
                removeCompleted: true,
                formData: { 'news_album_id': albumid },
                onSelect: function () {
                    $(".option").show();
                },
                onClearQueue: function () {
                    $(".option").hide();
                },
                onCancel: function (queueData) {
                    if (queueData.uploadQueue < 1) {
                        $(".option").hide();
                    }
                },
                onQueueComplete: function (queueData) {
                    if (queueData.uploadsErrored < 1) {
                        $(".option").hide();
                        alert("上传成功！");
                        window.location.href = "ShowPhoto.aspx?ID=" + albumid;
                    }
                    else {
                        alert("sorry，" + queueData.uploadsErrored + "个图片上传失败！");
                    }
                },
                onFallback: function () {
                    alert('您的浏览器不支持需要的FLASH！');
                }
            });
        });
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <asp:HiddenField ID="hdfAlbumid" runat="server" />
    <div id="fileQueue">
    </div>
    <input type="file" name="uploadify" id="uploadify" />
    <p>
        <a href="javascript:$('#uploadify').uploadify('upload','*')" class="option">上传</a>| <a
            class="option" href="javascript:$('#uploadify').uploadify('cancel','*')">取消上传</a>
    </p>
</asp:Content>
